#ifndef __EMBEDED_BROWSER__H_
#define __EMBEDED_BROWSER__H_

class ZEmbededBrowser:public CWindowImpl<ZEmbededBrowser,CAxWindow>
{
public:
	CComPtr<IWebBrowser2>   m_spWebBrowser;
	CComPtr<IUnknown>       m_spUnkSink;
	CComPtr<IAxWinHostWindow>  m_spHost;
	DWORD				    m_dwSinkCookie;	
	CToolBarCtrl*			m_Toolbar;
	BOOL					m_bHasFocus;
	BOOL					m_bDocumentCompleted;
	CComBSTR                m_bstrCurrentUrl;
	CComBSTR                m_bstrTitle;

public:
	DECLARE_WND_SUPERCLASS(NULL, CAxWindow::GetWndClassName())
	ZEmbededBrowser(BSTR bstrURL,BSTR bstrTitle)
	{
		m_dwSinkCookie = 0;
		m_spWebBrowser= NULL;
		m_spUnkSink= NULL;
		m_bHasFocus= FALSE;
		m_bDocumentCompleted = FALSE;
		m_bstrCurrentUrl = bstrURL;
		m_bstrTitle = bstrTitle ;
	}
	~ZEmbededBrowser();
	BOOL PreTranslateMessage(MSG* pMsg)
	{
		if((pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) &&
			(pMsg->message < WM_MOUSEFIRST || pMsg->message > WM_MOUSELAST))
			return FALSE;

		// give HTML page a chance to translate this message
		return (BOOL)SendMessage(WM_FORWARDMSG, 0, (LPARAM)pMsg);
	}

	BEGIN_MSG_MAP(ZEmbededBrowser)
		//MESSAGE_HANDLER(WM_KILLFOCUS,OnKillFocus)
		//MESSAGE_HANDLER(WM_SETFOCUS,OnSetFocus)
		MESSAGE_HANDLER(WM_CLOSE,OnClose)
		MESSAGE_HANDLER(WM_CREATE,OnCreate)
		//MESSAGE_HANDLER(WM_LBUTTONDOWN,OnClick)
		//MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST,WM_MOUSELAST,OnClick)
	END_MSG_MAP()
	LRESULT OnKillFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnClick(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	// Handler prototypes (uncomment arguments if needed):
	//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

public:
	void HideBrowser();
	BOOL HitOnButtonBlue();
};

#endif